''' 找到两个文件中的不同用户 '''

import csv
import os
# import numpy as np
import random
import requests

loginUserList = []
taskUserList = []
remainUserList = []
loginUser = 'F:/2019-07-11-login.csv'
taskUser = 'F:/2019-07-11-task.csv'
remainUser = 'F:/remainUser.csv'
with open(loginUser) as csvfile:
    csv_reader_login = csv.reader(csvfile)  # 使用csv.reader读取csvfile中的文件
    # csv_reader_login_header = next(csv_reader_login)  # 读取第一行每一列的标题
    for row in csv_reader_login:  # 将csv 文件中的数据保存到loginUserList中
        loginUserList.append(row)
with open(taskUser) as csvfile:
    csv_reader_task = csv.reader(csvfile)  # 使用csv.reader读取csvfile中的文件
    # csv_reader_task_header = next(csv_reader_task)  # 读取第一行每一列的标题
    for row in csv_reader_task:  # 将csv 文件中的数据保存到taskUserList中
        taskUserList.append(row)
#写文件
with open(remainUser,"w",newline='') as csvfile: 
    writer = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
    #先写入columns_name
    writer.writerow(["user_number"])
    #写入多行用writerows    
    for user in loginUserList:
        if user not in taskUserList:
            remainUserList.append(user)
            #writer.writerows(user) 
            print(user)
    writer.writerows(remainUserList) 
#writer.writerows(remainUserList)
#writer.writerows(user) 
